package file;

import org.junit.jupiter.api.Test;

import java.io.*;

public class FileCopyByBuffered {

    @Test
    public void copy() throws IOException {
        String srcFilePath = "D:\\aaaa\\test.txt";
        String desFilePath = "D:\\aaaa\\CopyByBufferedTest.txt";

        BufferedReader bufferedReader = new BufferedReader(new FileReader(srcFilePath));
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(desFilePath));

        String line;
        while ((line=bufferedReader.readLine())!=null){
            bufferedWriter.write(line);
            bufferedWriter.newLine();
        }

        bufferedReader.close();
        bufferedWriter.close();

    }

}
